t=int(input())
for inh in range(0,t):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(0,n):
x,y=a[i],b[i]
a[i]=max(x,y)
b[i]=min(x,y)
print(max(a)*max(b))
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int arr1[n],arr2[n];
int index1,index2;
int max1 = INT_MIN,max2=INT_MIN;
int ans = 0;
for(int i=0;i<n;i++){
cin>>arr1[i];
}
for(int i=0;i<n;i++){
cin>>arr2[i];
}
for(int i=0;i<n;i++){
if(arr1[i] < arr2[i]){
swap(arr1[i],arr2[i]);
}
}
for(int i=0;i<n;i++){
if(max1 < arr1[i]){
max1=arr1[i];
index1=i;
}
}
for(int i=0;i<n;i++){
if(max2 < arr2[i]){
max2 = arr2[i];
index2 = i;
}
}
cout<< max1 * max2 <<endl;
}
return 0;
}
519C - A and B and Team Training | 631A - Interview |
961B - Lecture Sleep | 522A - Reposts |
1166D - Cute Sequences | 1176A - Divide it |
1527A - And Then There Were K | 1618E - Singers' Tour |
1560B - Who's Opposite | 182B - Vasya's Calendar |
934A - A Compatible Pair | 1618F - Reverse |
1684C - Column Swapping | 57C - Array |
1713D - Tournament Countdown | 33A - What is for dinner |
810A - Straight A | 1433C - Dominant Piranha |
633A - Ebony and Ivory | 1196A - Three Piles of Candies |
299A - Ksusha and Array | 448B - Suffix Structures |
1092B - Teams Forming | 1166C - A Tale of Two Lands |
544B - Sea and Islands | 152B - Steps |
1174D - Ehab and the Expected XOR Problem | 1511A - Review Site |
1316A - Grade Allocation | 838A - Binary Blocks |